package org.cpoy.ei.session;

import org.cpoy.eims.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("teacherList")
public class TeacherList extends EntityQuery<Teacher> {

	private static final String EJBQL = "select teacher from Teacher teacher";

	private static final String[] RESTRICTIONS = {
			"lower(teacher.firstName) like lower(concat(#{teacherList.teacher.firstName},'%'))",
			"lower(teacher.lastName) like lower(concat(#{teacherList.teacher.lastName},'%'))",
			"lower(teacher.passportPhotoUrl) like lower(concat(#{teacherList.teacher.passportPhotoUrl},'%'))",
			"lower(teacher.subject) like lower(concat(#{teacherList.teacher.subject},'%'))",
			"lower(teacher.qualification) like lower(concat(#{teacherList.teacher.qualification},'%'))",
			"lower(teacher.comments) like lower(concat(#{teacherList.teacher.comments},'%'))", };

	private Teacher teacher = new Teacher();

	public TeacherList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Teacher getTeacher() {
		return teacher;
	}
}
